let slideIndex = 0;

function showSlides() {
  let slides = document.querySelectorAll('.slides img');
  slides.forEach(slide => slide.classList.remove('active'));
  slideIndex++;
  if (slideIndex > slides.length) {
    slideIndex = 1;
  }
  slides[slideIndex - 1].classList.add('active');
  setTimeout(showSlides, 5000);
}

function changeSlide(n) {
  slideIndex += n;
  let slides = document.querySelectorAll('.slides img');
  if (slideIndex > slides.length) {
    slideIndex = 1;
  }
  if (slideIndex < 1) {
    slideIndex = slides.length;
  }
  slides.forEach(slide => slide.classList.remove('active'));
  slides[slideIndex - 1].classList.add('active');
}

window.onload = function () {
  showSlides();
};